package com.dime.basic.service.impl;

import java.util.List;

import com.dime.basic.api.domain.DimeBasecontraindicationcriterion;
import com.dime.basic.mapper.DimeBaseoccupationaldiseaeMapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dime.basic.mapper.DimeBaseoccupationaldiseasecriterionMapper;
import com.dime.basic.api.domain.DimeBaseoccupationaldiseasecriterion;
import com.dime.basic.service.IDimeBaseoccupationaldiseasecriterionService;

/**
 * 职业诊断标准职业病Service业务层处理
 * 
 * @author Tiny
 * @date 2023-10-13
 */
@Service
public class DimeBaseoccupationaldiseasecriterionServiceImpl implements IDimeBaseoccupationaldiseasecriterionService 
{
    @Autowired
    private DimeBaseoccupationaldiseasecriterionMapper dimeBaseoccupationaldiseasecriterionMapper;

    @Autowired
    private DimeBaseoccupationaldiseaeMapper dimeBaseoccupationaldiseaeMapper;

    /**
     * 查询职业诊断标准职业病
     * 
     * @param id 职业诊断标准职业病主键
     * @return 职业诊断标准职业病
     */
    @Override
    public DimeBaseoccupationaldiseasecriterion selectDimeBaseoccupationaldiseasecriterionById(String id)
    {
        return dimeBaseoccupationaldiseasecriterionMapper.selectDimeBaseoccupationaldiseasecriterionById(id);
    }

    /**
     * 查询职业诊断标准职业病列表
     * 
     * @param dimeBaseoccupationaldiseasecriterion 职业诊断标准职业病
     * @return 职业诊断标准职业病
     */
    @Override
    public List<DimeBaseoccupationaldiseasecriterion> selectDimeBaseoccupationaldiseasecriterionList(DimeBaseoccupationaldiseasecriterion dimeBaseoccupationaldiseasecriterion)
    {
        return dimeBaseoccupationaldiseasecriterionMapper.selectDimeBaseoccupationaldiseasecriterionList(dimeBaseoccupationaldiseasecriterion);
    }

    /**
     * 新增职业诊断标准职业病
     * 
     * @param dimeBaseoccupationaldiseasecriterion 职业诊断标准职业病
     * @return 结果
     */
    @Override
    public int insertDimeBaseoccupationaldiseasecriterion(DimeBaseoccupationaldiseasecriterion dimeBaseoccupationaldiseasecriterion)
    {
        SetOccupationaldiseaeName(dimeBaseoccupationaldiseasecriterion);
        dimeBaseoccupationaldiseasecriterion.setId(IdUtils.fastUUID());
        dimeBaseoccupationaldiseasecriterion.setCreateTime(DateUtils.getNowDate());
        dimeBaseoccupationaldiseasecriterion.setCreateBy(SecurityUtils.getUsername());
        return dimeBaseoccupationaldiseasecriterionMapper.insertDimeBaseoccupationaldiseasecriterion(dimeBaseoccupationaldiseasecriterion);
    }

    private void SetOccupationaldiseaeName(DimeBaseoccupationaldiseasecriterion dimeBaseoccupationaldiseasecriterion) {
        String occupationaldiseaeName = dimeBaseoccupationaldiseaeMapper.selectDimeBaseoccupationaldiseaeById(dimeBaseoccupationaldiseasecriterion.getOccupationaldiseaeId()).getName();
        dimeBaseoccupationaldiseasecriterion.setOccupationaldiseaeName(occupationaldiseaeName);
    }

    /**
     * 修改职业诊断标准职业病
     * 
     * @param dimeBaseoccupationaldiseasecriterion 职业诊断标准职业病
     * @return 结果
     */
    @Override
    public int updateDimeBaseoccupationaldiseasecriterion(DimeBaseoccupationaldiseasecriterion dimeBaseoccupationaldiseasecriterion)
    {
        SetOccupationaldiseaeName(dimeBaseoccupationaldiseasecriterion);
        dimeBaseoccupationaldiseasecriterion.setUpdateBy(SecurityUtils.getUsername());
        dimeBaseoccupationaldiseasecriterion.setUpdateTime(DateUtils.getNowDate());
        return dimeBaseoccupationaldiseasecriterionMapper.updateDimeBaseoccupationaldiseasecriterion(dimeBaseoccupationaldiseasecriterion);
    }

    /**
     * 批量删除职业诊断标准职业病
     * 
     * @param ids 需要删除的职业诊断标准职业病主键
     * @return 结果
     */
    @Override
    public int deleteDimeBaseoccupationaldiseasecriterionByIds(String[] ids)
    {
        return dimeBaseoccupationaldiseasecriterionMapper.deleteDimeBaseoccupationaldiseasecriterionByIds(ids);
    }

    /**
     * 删除职业诊断标准职业病信息
     * 
     * @param id 职业诊断标准职业病主键
     * @return 结果
     */
    @Override
    public int deleteDimeBaseoccupationaldiseasecriterionById(String id)
    {
        return dimeBaseoccupationaldiseasecriterionMapper.deleteDimeBaseoccupationaldiseasecriterionById(id);
    }
}
